/**
 * 
 */
package com.gragra.nounIdentification.tests;
import static org.junit.Assert.*;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.junit.Before;
import org.junit.Test;
import com.gragra.data.MixingCorpus;
import com.gragra.data.MixingCorpusBaseImplementation;
import com.gragra.frameStatistics.StatisticsGenerator;
import com.gragra.nounIdentification.TypesPerTokenScorer;
import com.gragra.sampling.sequentialStructure.WordAndTagHolder;
import com.gragra.sequentiaDataGenerator.BaseGenerator;
import com.gragra.sequentiaDataGenerator.EmptySegmentation;
/**
 * @author Christoph Teichmann
 * 30.08.2013
 */
public class TestTypePerTokenScorer
{
	/**
	 * 
	 */
	private StatisticsGenerator sg;
	/**
	 * 
	 */
	private MixingCorpus<WordAndTagHolder> mc;
	/**
	 * 
	 */
	private TypesPerTokenScorer tpt;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		mc = new MixingCorpusBaseImplementation<WordAndTagHolder>();
		BaseGenerator bg = new BaseGenerator(new EmptySegmentation());
		mc.addData(bg.transferSingle("the|1 cow|2 is|3 very|4 hungry|5 .|6"));
		mc.addData(bg.transferSingle("the|1 principal|2 is|3 a|1 very|4 strict|5 man|2 .|6"));
		mc.addData(bg.transferSingle("my|7 aunt|2 is|3 a|1 very|4 strict|5 woman|2 .|6"));
		tpt = new TypesPerTokenScorer();
		sg = new StatisticsGenerator(mc, 3, 0, 0);
	}
	/**
	 * Test method for {@link com.gragra.nounIdentification.TypesPerTokenScorer#sortFrames(it.unimi.dsi.fastutil.ints.IntCollection, com.gragra.frameStatistics.StatisticsGenerator, it.unimi.dsi.fastutil.ints.IntSet, int)}.
	 */
	@Test
	public void testSortFramesIntCollectionStatisticsGeneratorIntSetInt()
	{
		IntList il = tpt.sortFrames(sg.getAllFrames(), sg, null, 0);
		assertEquals(sg.frameToString(il.getInt(0)),"< the _ is >");
		IntSet ib = new IntOpenHashSet(il);
		il = tpt.sortWords(sg.getAllWords(), sg, ib, 0);
	}
	/**
	 * Test method for {@link com.gragra.nounIdentification.TypesPerTokenScorer#getFrequent()}.
	 */
	@Test
	public void testGetFrequent()
	{
		tpt.sortFrames(sg.getAllFrames(), sg, null, 0);
		IntList il = tpt.getFrequent();
		assertEquals(il.size(),3);
	}
}